﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Mooc
{
    public partial class UpdateWorked : Form
    {
        public UpdateWorked(Work work, StuApp stuApp)
        {
            InitializeComponent();
            this.work = work;
            this.stuApp = stuApp;
            content.Text = work.W_content;
        }

        StuApp stuApp;

        Work work;
        SqlDao sqlDao = new SqlDao();

        private void submit_Click(object sender, EventArgs e)
        {
            if(MessageBox.Show("确定要修改作业?","警告",MessageBoxButtons.YesNo)==DialogResult.Yes)
            {
                work.W_content = content.Text;
                if (sqlDao.updateWork(work.W_id, work.S_id, content.Text)) {
                    MessageBox.Show("作业修改成功...");
                    stuApp.update(content.Text);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("作业修改失败...");
                }
            }
        }
    }
}
